package easy;

public class Solution_1309 {

    public String freqAlphabets(String s) {
        char[] chars = s.toCharArray();
        StringBuffer buffer = new StringBuffer();
        for (int i = chars.length - 1; i >= 0; i--) {
            if (chars[i] != '#') {
                buffer.append((char) (chars[i] - 49 + 'a'));
            } else {
                buffer.append((char) ((chars[i - 2] - 48) * 10 + chars[i - 1] - 49 + 'a'));
                i -= 2;
            }
        }
        return buffer.reverse().toString();
    }
    /*public String freqAlphabets(String s) {
        Map<String, String> map = new HashMap<>();
        map.put("1", "a");
        map.put("2", "b");
        map.put("3", "c");
        map.put("4", "d");
        map.put("5", "e");
        map.put("6", "f");
        map.put("7", "g");
        map.put("8", "h");
        map.put("9", "i");
        map.put("10#", "j");
        map.put("11#", "k");
        map.put("12#", "l");
        map.put("13#", "m");
        map.put("14#", "n");
        map.put("15#", "o");
        map.put("16#", "p");
        map.put("17#", "q");
        map.put("18#", "r");
        map.put("19#", "s");
        map.put("20#", "t");
        map.put("21#", "u");
        map.put("22#", "v");
        map.put("23#", "w");
        map.put("24#", "x");
        map.put("25#", "y");
        map.put("26#", "z");

        char[] chars = s.toCharArray();
        StringBuffer buffer = new StringBuffer();
        for (int i = chars.length - 1; i >= 0; i--) {
            if (chars[i] != '#') {
                buffer.append(map.get(new String(chars, i, 1)));
            } else {
                buffer.append(map.get(new String(chars, i - 2, 3)));
                i -= 2;
            }
        }
        return buffer.reverse().toString();
    }*/

    public static void main(String[] args) {
        Solution_1309 model = new Solution_1309();
        System.out.println(model.freqAlphabets("10#11#12"));
        System.out.println(model.freqAlphabets("1326#"));
        System.out.println(model.freqAlphabets("25#"));
        System.out.println(model.freqAlphabets("112345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#"));
        System.out.println('9'-0);
        System.out.println('0'-0);
    }
}
